
var userbetCount = 0;
var pageSize = 10;

function userbetList(page) {//, PlanCode, UserName, StartIssueNum, Status
    $.ajax({
        url: "/PersonalCenter/GetUserBetList",
        type: "post",
        data: { page: page, rows: pageSize },//, PlanCode: PlanCode, UserName: UserName, StartIssueNum: StartIssueNum, Status: Status
        dataType: "json",
        async: false,
        success: function (list) {
            userbetCount = list.total;
            $('#dg_UserBetList').html("<tr><th>期号</th><th>正</th><th>反</th><th>赚</th><th>开奖</th></tr>");//<th>操作</th>
            if (list.total > 0) {
                $.each(list.rows, function (i, n) {
                    $('#dg_UserBetList').append("<tr><td>" + n["issuenum"] + "</td>" +
                    "<td>" + n["zmoney"] + "</td>" +
                    "<td>" + n["fmoney"] + "</td>" +
                    "<td>" + bindMoney(n["winmoney"], n["zmoney"], n["fmoney"], n["lotterynum"]) + "</td>" +
                    "<td>" +bindNum( n["lotterynum"]) + "</td></tr>");//" +                    "<td><a href=\"/PersonalCenter/BetList?code=" + n["PlanCode"] + "\">查看</a></td>
                });
            }
            else {
                $('#dg_UserBetList').append("<tr><td colspan=\"6\">暂时没有数据...</td></tr>");
            }
        }
    });
}

userbetList(1);
//分页
$("#userbetPage").createPage({
    pageCount: userbetCount,
    pageSize: pageSize,
    current: 1,
    backFn: function (p) {
        userbetList(p);
    }
});

//$("#userBetListSearchBtn").click(function () {
//    userbetList(1, $("#PlanCode").val(), $("#UserName").val(), $("#StartIssueNum").val(), $("#Status").val());
//});
function bindMoney(win, zMoney, fMoney, num) {
    var res = "";
    if (win < 0) {
        res = "<span style='color:red;'>" + win + "</span>";
    }
    else {
        res = win;
    }
    return res;
}
function bindNum(num) {
    var res = "";
    if (num == 1) {
        res = "正";
    }
    if (num == 2) {
        res = "反";
    }
    return res;
}
